import http from "@/utils/http";
import { AxiosRequestConfig } from "axios";

export interface GetDownloadByTmpCode_ {
  /**
   * @description 模板类型, 1-原子指标,2-修饰词,3-维度,4-统计粒度,5-主题,6-派生指标
   */
  tmpCode: string;
}
export interface PostImportByTmpCode_ {
  /**
   * @description 模板类型, 1-原子指标,2-修饰词,3-维度,4-统计粒度,5-主题,6-派生指标
   */
  tmpCode: string;
}
export interface GetLogsByBatchNo_ {
  /**
   * @description 导入后返回的batchNo
   */
  batchNo: string;
}

export class Tmplate {
  /**
   * 导入模板下载
   *
   * @tags 导入导出controller
   * @request GET: /tmplate/download/{tmpCode}
   * @secure
   */
  getDownloadByTmpCode = ({ tmpCode }: { tmpCode: string } | GetDownloadByTmpCode_, params: AxiosRequestConfig = {}) =>
    http.request<void>({
      url: `/tmplate/download/${tmpCode}`,
      method: "GET",
      ...params,
    });

  /**
   * 批量导入
   *
   * @tags 导入导出controller
   * @request POST: /tmplate/import/{tmpCode}
   * @secure
   */
  postImportByTmpCode = (
    { tmpCode }: { tmpCode: string } | PostImportByTmpCode_,
    data: { uploadFile: File },
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityImportResVO>({
      url: `/tmplate/import/${tmpCode}`,
      method: "POST",
      data: data,
      ...params,
    });

  /**
   * 导入结果excel下载
   *
   * @tags 导入导出controller
   * @request GET: /tmplate/logs/{batchNo}
   * @secure
   */
  getLogsByBatchNo = ({ batchNo }: { batchNo: string } | GetLogsByBatchNo_, params: AxiosRequestConfig = {}) =>
    http.request<void>({
      url: `/tmplate/logs/${batchNo}`,
      method: "GET",
      ...params,
    });
}

export default new Tmplate();
